/*

Author: Jake Flynt
11/24/13

GameController.cpp

Implementation for the GameController class, which handles the logic for the overall program

 */

#include "GameController.h"
#include "situationControl/SituationController.h"
#include "keyboard_input/KeyboardHandler.h"
#include "networkIO/networkHandler.h"
#include "glOutput/Graphics.h"
#include <boost/thread/thread.hpp>


//constructor
GameController::GameController() {

  //initalize situation controller, keyboard handler, network handler, and graphics
  SituationController *mSC = new SituationController();
  KeyboardHandler *mKH = new KeyboardHandler(7, mSC);

  Graphics *glWindow = new Graphics();
  glWindow->acceptKeyboardHandler(mKH);
  glWindow->initScene(0, NULL);

  networkI::networkHandler *mNH = new networkI::networkHandler();
  mSC->acceptGraphics(glWindow);
  mSC->setNetwork(mNH);
  boost::thread t(boost::bind(&boost::asio::io_service::run, mNH->getIOservice()));
  fprintf(stderr, "done\n");

}

void GameController::run() {

  //loop
  while(1) {
    //mSC->tick();
    usleep(250);
  }
}
